//ui 时间控件判断js
function timetime(){
  var today=new Date();
  var t=today.getTime()-1000*60*60*24;
  var yesterday=new Date(t);
  var startDate = yesterday;
  var endDate = yesterday;
  var $alert = $('#my-alert');
  $('#my-start').datepicker().on('changeDate.datepicker.amui', function(event) {
	  if (event.date.valueOf() > endDate.valueOf()) {
		$alert.find('p').text('开始日期应小于结束日期！').end().show();
	  } else {
		$alert.hide();
		startDate = new Date(event.date);
		$('#my-startDate').val($('#my-start').data('date'));
	  }
	  $(this).datepicker('close');
	});

  $('#my-end').datepicker().on('changeDate.datepicker.amui', function(event) {
	  if (event.date.valueOf() < startDate.valueOf()) {
		$alert.find('p').text('结束日期应大于开始日期！').end().show();
	  } else {
		$alert.hide();
		endDate = new Date(event.date);
		$('#my-endDate').val($('#my-end').data('date'));
	  }
	  $(this).datepicker('close');
	});
  
}

var time="";
time+='<div class="timetcc">';
time+='	<div class="am-alert am-alert-danger" id="my-alert" style="display: none;padding: .225em;position:absolute;bottom:-10px;">';
time+='	  <p>开始日期应小于结束日期！</p>';
time+='	</div>';
time+='	<div>';
time+='		开始时间：';
time+='		<div class="ksjstime">';
time+='			<input type="text" placeholder="" readonly=readonly id="my-startDate"> ';
time+='			<span class="am-icon-calendar" id="my-start"></span>';
time+='		</div>';
time+='	</div>';
time+='	<div>';
time+='		结束时间：';
time+='		<div class="ksjstime">';
time+='			<input type="text" placeholder="" readonly=readonly id="my-endDate"> ';
time+='			<span class="am-icon-calendar" id="my-end"></span>';
time+='		</div>';
time+='	</div>';
time+='	<div class="am-text-right">';
time+='		<button class="am-btn am-btn-sm am-btn-primary am-radius" type="button" style="padding:5px 8px;" onClick="timehide()">确定</button>';
time+='	</div>';
time+='</div>';

//时间控件div弹出、隐藏
function timeshow(){
	$(".timediv").append(time);
	timetime();
}
function timehide(){
	var startdate=$("#my-startDate").val();
	$("#starttime").attr("value",startdate);
	
	var enddate=$("#my-endDate").val();
	$("#endtime").val(enddate);
	
	$(".timetcc").remove();
}

//时、分的监控
function hour(obj){
	var hour=$(obj).val();
	if(hour > 24){
		$(obj).val(24);
	}else if(hour <=  0){
		$(obj).val(0);
	}
}
function second(obj){
	var second=$(obj).val();
	if(second > 60){
		$(obj).val(60);
	}else if(second <= 0){
		$(obj).val(0);
	}
}

